---
title: "User Data"
description: "REST endpoints for managing user data and settings"
---

## Set DateTime

Update the user's datetime setting and notify subscribed apps.

### Endpoint

<CodeGroup>
```bash Production
POST https://api.mentra.glass/api/user-data/set-datetime
```

```bash Development
POST https://devapi.mentra.glass/api/user-data/set-datetime
```

```bash Local
POST http://localhost:8002/api/user-data/set-datetime
```
</CodeGroup>

### Request Body

```json
{
  "coreToken": "eyJhbGciOiJIUzI1NiIs...",
  "datetime": "2024-01-20T10:30:00Z"
}
```

<Note>
The datetime must be in ISO 8601 format.
</Note>

### Response

Success (200):
```json
{
  "success": true,
  "userId": "user@example.com",
  "datetime": "2024-01-20T10:30:00Z"
}
```

Error (400):
```json
{
  "error": "Missing or invalid coreToken or datetime (must be ISO string)"
}
```

Error (401):
```json
{
  "error": "Invalid core token - missing user email" // or "Invalid or expired core token"
}
```

Error (404):
```json
{
  "error": "User session not found"
}
```

### Implementation

- **File**: `packages/cloud/src/routes/user-data.routes.ts:17-70`
- **Authentication**: JWT token validation using `AUGMENTOS_AUTH_JWT_SECRET`
- **Side Effects**: Sends CUSTOM_MESSAGE to all apps subscribed to custom messages

### Custom Message Format

Apps subscribed to `CUSTOM_MESSAGE` stream will receive:

```json
{
  "type": "CUSTOM_MESSAGE",
  "action": "update_datetime",
  "payload": {
    "datetime": "2024-01-20T10:30:00Z",
    "section": "topLeft"
  },
  "timestamp": "2024-01-20T10:30:00.000Z"
}
```

### Usage Notes

- The coreToken is passed in the request body rather than as a header
- This endpoint stores the datetime in the user's session as `userDatetime`
- Only apps that have subscribed to the `CUSTOM_MESSAGE` stream type will receive the update
- The datetime is used for display purposes on the glasses

## Error Codes

| Code | Description |
|------|-------------|
| 400 | Missing or invalid parameters |
| 401 | Invalid or expired core token |
| 404 | User session not found - user must have active WebSocket connection |